﻿using System;


using System.Text;
using IAM.Interface.Model.Interface;
using IAM.Interface.Model.ENUM;
using System.Web;

namespace IAM.Interface.Model
{
    /// <summary>
    /// 组织机构基本信息
    /// </summary>
    public class OrganizeBaseInfo : AbstractConvertObject,IConvertXml
    {
        #region 属性
        private string _orgid = "";
        private OrganizeType _orgtype = OrganizeType.BD;
        private string _orgapbr = "";
        private string _orgname = "";
        private string _orgcname = "";
        private string _adminid = "";

        /// <summary>
        /// 组织机构标识
        /// </summary>
        public string OrgID
        {
            get
            {
                return _orgid;
            }
            set
            {
                _orgid = value;
            }
        }
        /// <summary>
        /// 组织机构类型。包括BG，BD和BU
        /// </summary>
        public OrganizeType OrgType
        {
            get
            {
                return _orgtype;
            }
            set
            {
                _orgtype = value;
            }
        }
        /// <summary>
        /// 组织机构简称
        /// </summary>
        public string OrgAPBR
        {
            get
            {
                return _orgapbr;
            }
            set
            {
                _orgapbr = value;
            }
        }
        /// <summary>
        /// 组织机构名称
        /// </summary>
        public string OrgName
        {
            get
            {
                return _orgname;
            }
            set
            {
                _orgname = value;
            }
        }
        /// <summary>
        /// 组织机构中文名称
        /// </summary>
        public string OrgCName
        {
            get
            {
                return _orgcname;
            }
            set
            {
                _orgcname = value;
            }
        }
        /// <summary>
        /// 上级机构编号
        /// </summary>
        public string AdminID
        {
            get
            {
                return _adminid;
            }
            set
            {
                _adminid = value;
            }
        }
        #endregion
        #region IConvertXml

        public string XMLBoday
        {
            get
            {
                StringBuilder xml = new StringBuilder();

                xml.Append("<OrgID>" + IAM.Interface.Common.EnDeCoding.Encode(this.OrgID )+ "</OrgID>");
                xml.Append("<OrgType>" + this.OrgType.ToString() + "</OrgType>");
                xml.Append("<OrgAPBR>" + IAM.Interface.Common.EnDeCoding.Encode(this.OrgAPBR )+ "</OrgAPBR>");
                xml.Append("<OrgName>" + IAM.Interface.Common.EnDeCoding.Encode(this.OrgName )+ "</OrgName>");
                xml.Append("<OrgCName>" + IAM.Interface.Common.EnDeCoding.Encode(this.OrgCName )+ "</OrgCName>");
                xml.Append("<AdminID>" + IAM.Interface.Common.EnDeCoding.Encode(this.AdminID )+ "</AdminID>");
              

                return xml.ToString();
            }


        }

        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
        public string XML
        {
            get
            {
                return XMLBoday + XMLFinis;
            }
        }
        #endregion
        #region AbstractConvertObject
        public override object ConvertToObject()
        {
            //1.获取当前结点
            this.OrgID = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgID").InnerText);
            string strType = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgType").InnerText);
            switch(strType.ToLower())
            {
                case"bd":
                    this.OrgType=OrganizeType.BD;
                    break;
                case "bg":
                    this.OrgType = OrganizeType.BG;
                    break;
                case "bu":
                    this.OrgType = OrganizeType.BU;
                    break;
            }
            this.OrgAPBR = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgAPBR").InnerText);
            this.OrgName = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgName").InnerText);
            this.OrgCName = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgCName").InnerText);
            this.AdminID = IAM.Interface.Common.EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("AdminID").InnerText);
            return this;
        }
        #endregion
    }
}
